//
//  PolicyCell.m
//  阿帕
//
//  Created by mac on 2020/1/6.
//  Copyright © 2020 GCY. All rights reserved.
//

#import "PolicyCell.h"

@implementation PolicyCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    NSArray *titleArr = @[@"保险种类:",@"保单号:",@"货源单号:",@"运输单号:",@"货主:",@"承运人司机:",@"车牌号:"];
    for (int i=0; i<titleArr.count; i++) {
        
        UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 30 * i + 10, ScreenW, 30)];
        [self.contentView addSubview:bgView];
        
        CGSize size = [DCSpeedy dc_calculateTextSizeWithText:titleArr[i] WithTextFont:14 WithMaxW:1000];
        
        UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, size.width, bgView.cy_height)];
        textLabel.text = titleArr[i];
        textLabel.textColor = Dark_TextColor;
        textLabel.font = font(14);
        textLabel.adjustsFontSizeToFitWidth = YES;
        [bgView addSubview:textLabel];
        
        UILabel *valueLabel = [[UILabel alloc] initWithFrame:CGRectMake(textLabel.cy_right + 5, 0, ScreenW-size.width-5, bgView.cy_height)];
        valueLabel.tag = 100+i;
        valueLabel.text = @"-";
        valueLabel.textColor = Light_TextColor;
        valueLabel.font = font(14);
        valueLabel.numberOfLines = 2;
        valueLabel.adjustsFontSizeToFitWidth = YES;
        [bgView addSubview:valueLabel];
    }
    
    //分割线
    UIView *hLine = [[UIView alloc] initWithFrame:CGRectMake(0, 229, ScreenW, 1)];
    hLine.backgroundColor = BackgroundColor;
    [self.contentView addSubview:hLine];
}

- (void)setModel:(PolicyRecordModel *)model {
    
    _model = model;
    
    NSArray *arr = @[[NSString nullToString:model.productName],//保险种类
                     [NSString nullToString:model.policyNo],//保单号
                     [NSString nullToString:model.mainOrderNumber],//货源单号
                     [NSString nullToString:model.orderDetailNumber],//运输单号
                     [NSString nullToString:model.orderCreatedByName],//货主
                     [NSString nullToString:model.driverName],//承运人司机
                     [NSString nullToString:model.vehicleLicense],//车牌号
    ];

    for (int i=0; i<arr.count; i++) {
        UILabel *valueLabel = [self viewWithTag:100 + i];
        valueLabel.text = arr[i];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
